package net.oschina.aibinxiao.job;

import lombok.Setter;
import org.quartz.*;

import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * @Author: AiBinXiao
 * @Description: 浅谈Trigger
 * @Date: 2017/10/12 8:35
 */

public class HelloJob3 implements Job{

    public void execute(JobExecutionContext context) throws JobExecutionException {
        // 打印当前时间，格式为 yyyy-MM-dd HH:mm:ss
        Date date = new Date();
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");

        String dateStr = sdf.format(date);
        System.out.println("当前时间是：" + dateStr);

        Trigger currentTrigger = context.getTrigger();
        System.out.println("Trigger's startTime is:" + sdf.format(currentTrigger.getStartTime()));
        System.out.println("Trigger's endTime is:" + sdf.format(currentTrigger.getEndTime()));
        JobKey jobKey = currentTrigger.getJobKey();
        System.out.println("JobKey info: jobName is " + jobKey.getName() + " jobGroup is " + jobKey.getGroup());

    }
}
